# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gdk-pixbuf
pkgver=2.42.11
pkgrel=1
pkgdesc="GTK+ image loading library"
url="https://wiki.gnome.org/Projects/GdkPixbuf"
arch="all"
license="LGPL-2.1-or-later"
depends="shared-mime-info"
makedepends="
	glib-dev
	gobject-introspection-dev
	libjpeg-turbo-dev
	libpng-dev
	meson
	py3-docutils
	tiff-dev
	"
install="$pkgname.pre-deinstall"
triggers="$pkgname.trigger=/usr/lib/gdk-pixbuf-2.0/*/loaders"
subpackages="$pkgname-dbg $pkgname-doc $pkgname-lang $pkgname-dev $pkgname-loaders"
source="https://download.gnome.org/sources/gdk-pixbuf/${pkgver%.*}/gdk-pixbuf-$pkgver.tar.xz
	0001-fix-build-failure-due-to-typo-in-the-build-script.patch
	"

case "$CARCH" in
x86|arm*)
	# https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/215
	options="$options !check"
esac

# secfixes:
#   2.42.8-r0:
#     - CVE-2021-44648
#   2.42.2-r0:
#     - CVE-2020-29385
#   2.36.6-r1:
#     - CVE-2017-6311
#     - CVE-2017-6312
#     - CVE-2017-6314

build() {
	abuild-meson \
		-Db_lto=true \
		-Dinstalled_tests=false \
		-Dothers=enabled \
		-Dtests="$(want_check && echo true || echo false)" \
		output .
	meson compile -C output
}

check() {
	meson test -t 10 --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

loaders() {
	pkgdesc="Metapackage to pull in gdk-pixbuf loaders"
	mkdir -p "$subpkgdir"
}

sha512sums="
582ea4eee2bfe0824175c35f56baf72799585f90ac86069a781830830b605f4cd93f5c6eafab80f4f7354f8f9d51d157ae89eda6eb1e32a0e51de37d7f6290cc  gdk-pixbuf-2.42.11.tar.xz
45420d8f4119c222768f7477fafa4ffcbd479948f5b6d06f74726700b1645579fb6647f81247b0b281dcde0df010c7811c954021f2a477a88a40acd232247336  0001-fix-build-failure-due-to-typo-in-the-build-script.patch
"
